package com.studor.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.studor.entity.Room;
import com.studor.mapper.RoomMapper;
import com.studor.service.RoomService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoomServiceImpl extends ServiceImpl<RoomMapper, Room> implements RoomService {

    @Override
    public List<Room> getAvailableRooms(String dormitory, Integer floor) {
        QueryWrapper<Room> wrapper = new QueryWrapper<>();
        wrapper.eq("dormitory", dormitory);
        if (floor != null) {
            wrapper.eq("floors", floor);
        }
        return this.list(wrapper);
    }
} 